#ifndef ABSTABLE_H
#define ABSTABLE_H

#include <QObject>
#include <QSqlDatabase>
#include <QSqlRecord>
#include <QDebug>
#include <QSqlRecord>
#include <QSqlField>
#include <QSqlError>
#include <QSqlQuery>

struct StSqlResult{
    QSqlRecord header;
    QList<QVariantList> data;
};

struct StRowData
{
    virtual void loadData(QVariantList varList) = 0;
    virtual QVariantList getData() = 0;
    QVariantList rowData;
};

class AbsTable : public QObject
{
    Q_OBJECT
public:
    explicit AbsTable(QString strTableName,QObject *parent = nullptr);

    virtual bool createTable() = 0;
    virtual bool dropTable();
    virtual bool exisit();

    QSqlDatabase *dbConnection();
    QStringList columnNames();
    bool execSql(QString strSql);
    bool exec(QSqlQuery &query);

    bool transaction(); //开启事务
    bool commit();      //事务提交
public:

protected:
    QString m_strTableName;
    QStringList m_strListColumnNames;
};

#endif // ABSTABLE_H
